#include "stdafx.h"
#include "worldSceneControl.h"
#include "UIMain.h"
#include "RightWnd.h"
#include "InspectorWnd.h"
#include "Engine.h"

void CWorldSceneControl::onMouseEvent(mini::event& e)
{
	auto pScene = mini::GEngine->getCurrentScene();
	if (mini::MSG_TYPE::LEFTUP == e.Messtype)
	{
		auto pPickEntity = pScene->calculationPickEntity((float)e.point.x, (float)e.point.y);
		if (nullptr != mini::ui::CUIMain::pMySelf)
		{
			auto pWnd = mini::ui::CUIMain::pMySelf->findWnd("RightWnd");
			if (nullptr != pWnd)
			{
				CRightWnd* pRightWnd = dynamic_cast<CRightWnd*>(pWnd);
				CInspectorWnd* pInspectorWnd = pRightWnd->getInspectorWnd();
				pInspectorWnd->setPickActor(dynamic_cast<mini::CActor*>(pPickEntity));
			}
		}
	}
	else if (mini::MSG_TYPE::MOUSEMOVE == e.Messtype)
	{
		auto pPickEntity = pScene->calculationPickEntity((float)e.point.x, (float)e.point.y);
		if (nullptr != pPickEntity)
		{
			mpPickActor = dynamic_cast<mini::CActor*>(pPickEntity);
			if (nullptr != mpPickActor)
			{
				mpPickActor->showBoundBox();
			}
		}
		else
		{
			if (nullptr != mpPickActor)
			{
				mpPickActor->hideBoundBox();
			}
		}
	}
}
